import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path"
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
    }),
  ],
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
      'vue-router': resolve(__dirname, 'node_modules/vue-router')
    }
  },
  server: {
    host: '0.0.0.0',
    proxy: {
      '/m1': {
        target: 'https://api.m.hotread.com/', // 目标服务器的地址  
        changeOrigin: true, // 开启跨域代理  
        rewrite: (path) => path.replace(/^\/api/, '') // 如果需要去除代理前缀  
      },
      '/h5': {
        target: "http://192.168.24.18:5555",
        changeOrigin: true, // 开启跨域代理  
        rewrite: (path) => path.replace(/^\/api/, '') // 如果需要去除代理前缀  
      },
      '/event': {
        target: "https://mobile.hotread.com/",
        changeOrigin: true
      },
      '/informationflow': {
        target: "https://index-api.2345.com",
        changeOrigin: true
      },
      '/api': {
        target: "https://www.hao123.com/",
        changeOrigin: true
      },
    }
  }

})
